package com.hps.spring.cloud.alibaba.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author heps
 * @since 2020/11/3 14:50
 */
@RestController
public class NacosProviderController {

  @Value("${server.port}")
  private String port;

  @Autowired
  private ConfigurableApplicationContext applicationContext;

  @GetMapping(value = "/test/{message}")
  public String test(@PathVariable String message) {
    return "Hello Nacos Discovery " + message + " i am from port " + port;
  }

  @GetMapping(value = "/hi")
  public String sayHi() {
    return "Hello " + applicationContext.getEnvironment().getProperty("user.name");
  }
}
